onchangeListener = function() 
{
    var html = FCKeditorAPI.GetInstance("body").GetHTML();
    var message = "You've written about " + countWords(removeHTML(html)) + " out of 100 words.";
    document.getElementById("textlength").innerHTML = message;
}

function removeHTML( strText )
{
    var text = strText.replace("&nbsp;", "");
    text = text.replace(/<\/p>/g, " ");
	text = text.replace(/<[^>]*>/g, "");
    text = text.replace(/&nbsp;/g, " ");
    text = text.replace(/&amp;/g, "&");
    text = text.replace(/&lt;/g, "<");
    text = text.replace(/&gt;/g, ">");
    return text;
}

function countWords( strText )
{
	var words = strText.split(/\s+/g);
	var wordCount = words.length;
	return wordCount;
}

function FCKeditor_OnComplete( editorInstance )
{
    FCKeditorAPI.GetInstance("body").EditorDocument.onkeypress = onchangeListener;
}